package cn.somkit.fmt.socket;

import org.springframework.web.socket.WebSocketSession;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class SocketManage {

    private SocketManage() {
    }

    private static final Map<String, WebSocketSession> onlineMap = new ConcurrentHashMap<>();

    public static void put(WebSocketSession session){
        onlineMap.put(session.getId(), session);
    }

    public static WebSocketSession get(String sessionId){
        return onlineMap.get(sessionId);
    }

    public static void remove(String sessionId){
        onlineMap.remove(sessionId);
    }

    public static List<WebSocketSession> all(){
        return onlineMap.values().stream().toList();
    }
}
